package com.woniuxy.carrental.xiaomoutest;

import com.woniuxy.carrental.entity.*;
import com.woniuxy.carrental.mapper.*;
import com.woniuxy.carrental.service.DetailsService;
import com.woniuxy.carrental.service.PurchaseService;
import com.woniuxy.carrental.service.StoreService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-09-28 10:59
 */
@SpringBootTest
public class xiaoMouTestMapper {
    @Resource
    StoreMapper storeMapper;

    //测试向表中添加数据
//    @Test
//////    void testAdd(){
//////        storeMapper.insertStore
//////                (new Store(null, "天府一店", "9.00-18.00", "肖某", "18282146591",
//////                        "四川省成都市孵化园",
//////                        "新店开张", "2021.9.28-2021.11.30",
//////                        "本店新店开张 全场8折限时35天！"));
//////    }

    //测试查询表中所有数据
    @Test
    void selectStore(){
        List<Store> stores = storeMapper.selectStore();
        System.out.println(stores);
    }

//    测试修改门店信息
//    @Test
//    void updataStore(){
//        storeMapper.updataStore(new Store(1,
//                "天府起飞店", "9.00-17.30", "肖某某", "1828214591",
//                "四川省成都市 天府新区", "首单立减1888",
//                "2021.9.28-2021.11.30", "本店新店开张 全场8折限时35天！"));
//    }

    //根据指定id删除门店
    @Test
    void deleteStore(){
        storeMapper.deleteStore(1);
    }


    //模糊查询
    @Test
    void test1(){
        List<Store> list = storeMapper.selectStoreByLike("天");
        System.out.println(list);
    }

    //根据id查询表中数据
    @Test
    void testselectStoreByStoreid(){
//        Store storea = storeMapper.selectStoreByStoreid(3);
        Store storeas = storeMapper.selectStoreByStoreid(3);
        System.out.println(storeas);
    }

    //总条数查询
    @Test
    void testfenye1(){
        int i = storeMapper.selectCountStore();
        System.out.println(i);
    }

    //分页查询
//    @Test
//    void testfenyechaxun(){
//        Store store = new Store();
//        List<Store> stores = storeMapper.selectStoresByPage(store, 2, 2);
//        System.out.println(stores);
//    }




    //------------------------------------------------类型表单测试watype

    @Resource
    WatypeMapper watypeMapper;

    @Test
    void testinsertwa(){
        Watype watype=new Watype();
        watype.setWatypename("豪华车");
        watypeMapper.insertWatype(watype);
    }

    //测试根据名称查询表中数据
//    @Test
//    void testselect(){
//        System.out.println(watypeMapper.selectWatype("豪华车"));
//    }


    @Resource
    PurchaseMapper purchaseMapper;
    //根据id查询表中数据
//    @Test
//    public void select(){
//        Purchase purchase = purchaseMapper.selectPuByid("0DE5320BDD5C4CF5A6CD32BA30DD4297");
//        System.out.println(purchase);
//    }


    //根据名称查询表中数据
    @Resource
    CarMapper carMapper;

    @Test
    void selectCar(){
        Car car = carMapper.selectCarByName("五菱宏光");
        System.out.println(car);
    }

    //根据名称查询汽配表
    @Resource
    CarpartMapper carpartMapper;

    @Test
    void selecrcarpart(){

        System.out.println(carpartMapper.selectByName("方向盘"));
    }

    //测试向仓库添加数据
    @Resource
    DetailsService detailsService;

    @Test
    public void addDe(){
        detailsService.insertDe("1859DBCEEF3C4692BF33376DEE9895A8");
    }

    //根据名称查询仓库数据
    @Resource
    DetailsMapper detailsMapper;

    @Test
    void test11(){
        System.out.println(detailsMapper.selectByName("机油泵丰田专用"));
        Details sa = detailsMapper.selectByName("机油泵丰田专用");
        String debrand = sa.getDebrand();
//        sa.
    }

    //修改物品数量
    @Test
    void test12(){
        detailsMapper.updataCountByName(2,"机油泵丰田专用");
    }

    //查询所有可以入库的订单
    @Test
    void test13(){
        List<Purchase> purchases = purchaseMapper.selectAllBytrue();
        System.out.println(purchases);
    }
    //成功入库后将状态由true改为false
    @Test
    void test14(){
        purchaseMapper.updataByState("C4FC877D94974DB5A1CB4BBD710FF4F5");
    }

    @Resource
    StoreService storeService;
//测试修改
    @Test
    void test15(){
        Store store=new Store();
        store.setStoreid(25);
        store.setSname("万州烤鱼");
        storeService.updataStoreService(store);
    }

    //入库订单分页查询
    @Resource
    WareingMapper wareingMapper;

    @Test
    void test16(){
        Wareing wareing=new Wareing();
        wareing.setWareingname("车");
        ;
        System.out.println(wareingMapper.selectWareingByPage(wareing,5, 5));
    }

    //测试排序
    @Test
    void test17(){
        System.out.println(wareingMapper.selectAll());
    }

    @Resource
    PurchaseService purchaseService;
    @Test
    public void test18(){

//        System.out.println(purchaseService.selectAllByTrue());
        System.out.println(purchaseMapper.selectAllBytrue());
    }

    @Test
    void test19(){
        //System.out.println(purchaseMapper.selectAllBytrue());

//        System.out.println(purchaseService.selectAllByTrue());

        System.out.println(detailsMapper.selectByIdOne(1));
    }


}
